package com.itheima.health.mapper;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.itheima.health.pojo.CheckGroup;
import com.itheima.health.pojo.CheckItem;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface CheckGroupMapper extends BaseMapper<CheckGroup> {

    @Insert("insert into t_checkgroup_checkitem values(#{id},#{checkitemId})")
    void addCheckGroupAndCheckItemIds(@Param("id") Integer id, @Param("checkitemId") Integer checkitemId);

    @Select("select CHECKITEM_ID from t_checkgroup_checkitem where CHECKGROUP_ID = #{id}")
    List<Integer> findCheckItemIdsByGroupId(@Param("id") int id);

    @Delete("delete from t_checkgroup_checkitem where CHECKGROUP_ID = #{id}")
    void relieveByGroupId(@Param("id")Integer id);


    @Select("select t2.`NAME` FROM t_checkgroup_checkitem t1, t_checkitem t2 WHERE t2.ID = t1.CHECKITEM_ID and t2.IS_DELETE = 0 AND t1.CHECKGROUP_ID = #{id}")
    List<CheckItem> findCheckItemsByGid(@Param("id") Integer id);
}
